<template>
  <div>
    <!-- 全局加载状态 -->
    <FullLoading v-if="isFullLoading" />
    <!-- Nuxt 布局系统 -->
    <NuxtLayout>
      <NuxtPage />
    </NuxtLayout>
  </div>
</template>

<script setup lang="ts">
import { useTheme } from '~/composables/useTheme';

const route = useRoute()
useTheme();

// 判断是否是首页路由
const isHomeRoute = computed(() => {
  const homeRoutes = ['/home'] // 可以根据需要添加更多被视为首页的路由
  return homeRoutes.includes(route.path)
})

// 判断是否显示AppHeader
// const shouldShowHeader = computed(() => {
//   // 在这里添加需要隐藏Header的路由路径
//   const hiddenHeaderRoutes = ['/login', '/register', '/admin', '/details', '/admin']
//   return !hiddenHeaderRoutes.includes(route.path)
// })
const shouldShowHeader = computed(() => {
  const hiddenPatterns = [
    /^\/login(\/|$)/,
    /^\/register(\/|$)/,
    /^\/details(\/|$)/,
    /^\/admin(\/|$)/,
    /^\/comCollection(\/|$)/,
    /^\/product(\/|$)/,
    /^\/theme(\/|$)/,
    /^\/vodeos(\/|$)/
  ]
  return !hiddenPatterns.some(regex => regex.test(route.path))
})

const nuxtApp = useNuxtApp()

// 是否首次加载
const isFullLoading = ref(true)

nuxtApp.hook('page:start', () => {
  isFullLoading.value = true
})

nuxtApp.hook('page:finish', () => {
  isFullLoading.value = false
})
</script>
